{% extends '::backend.html.twig' %}
{% block contenido %}
         {% include 'BackendBundle:Default:flashAlerts.html.twig'%}

<legend>Cambiar Contraseña</legend>
<form class="form-horizontal" action="{{ path('user_update_password') }}" {{ form_enctype(form) }} method="POST">
    <fieldset>
        <div class="control-group">
            <label class="control-label required">Contras&ntilde;a</label>
               {{ form_errors(form.password) }}
           <div class="controls">
               {{ form_widget(form.password) }}
           </div>
       </div>
        <div class="form-actions">
           <button type="submit" class="btn btn-success">
               <i class="icon-ok icon-black"></i> Aceptar
           </button>
           <a class="btn btn-danger" href="{{ path('user_perfil') }}">
               <i class="icon-remove icon-black"></i> Cancelar
           </a>
       </div>
    </fieldset>
</form>


{% endblock %}
{% block documentReadyJavascript %}
    {{ parent() }}
<script type="text/javascript">

    $(".save").on('click', function(){
        return validateAjaxInputs();
    });
        
    function validateAjaxInputs() {
        $.validity.setup({
            outputMode:"bootstrap"                
        });

        $.validity.start();

     
        //validacion campo contraseña
        $("input[type='password']")
        .require("Es obligatorio")
        .match(/^(?=^.{6,}$)((?=.*[A-Za-z0-9]))^.*$/, "La contraseña debe tener al menos 6 caracteres  alfanumericos")
        .equal("Las contraseñas no son iguales."); 
       

        var result = $.validity.end();

        // Return whether it's okay to proceed with the Ajax:
        return result.valid;
    }
    </script>
{% endblock documentReadyJavascript %}